package com.wjh.anyview.controller;

import com.wjh.anyview.entity.dto.CommonResult;
import com.wjh.anyview.service.impl.PublisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wjh
 * @date 2021/10/11 21:08
 * @Package com.example.demo.controller
 */
@RestController
@RequestMapping("/api/publisher")
public class PublisherController {

    @Autowired
    private PublisherService publisherService;

    @RequestMapping("/sendMessage/{message}")
    @PreAuthorize("hasAuthority('/sendMessage')")
    public CommonResult<String> sendMessage(@PathVariable("message") String message) {
        return publisherService.sendMessage(message);
    }

    @RequestMapping("/sendBeginExamMessage/{message}/{numList}/{examId}")
    @PreAuthorize("hasAuthority('/sendBeginExamMessage')")
    public CommonResult<String> sendBeginExamMessage(@PathVariable("message") String message, @PathVariable("numList") String numList, @PathVariable("examId") Long examId) {
        return publisherService.sendBeginExamMessage(message, numList, examId);
    }

    @RequestMapping("/delayExam/{examId}/{delayTime}")
    @PreAuthorize("hasAuthority('/delayExam')")
    public CommonResult<String> delayExam(@PathVariable("examId") Long examId, @PathVariable("delayTime") Integer delayTime) {
        return publisherService.delayExam(examId, delayTime);
    }

}